var handler = require('./handler.js');
var fs = require('fs');
var path = require('path');

module.exports = function (req, res) {
    if(req.url == '/') {
        handler.home(req, res);
    }else if(req.url == '/login'){
        handler.login(req, res);
    }
    else if(req.url == '/enroll'){
        handler.enroll(req, res);
    }
    /*else if(req.url.startsWith ('/geren')){
        handler.geren(req, res);
    }*/
    else if(req.url == '/charu'){
        handler.charu(req, res);
    }
    else if(req.url == '/tianjia'){
        handler.tianjia(req, res);
    }else if(req.url == '/insert'){
        handler.insert(req, res);
    }
    else if(req.url == '/plug'){
        handler.plug(req, res);
    }
    else if(req.url == '/list'){
        handler.list(req, res);
    }else if(req.url == '/info'){
        handler.info(req, res);
    }
    else if(req.url == '/found'){
        handler.found(req, res);
    }
    else if(req.url.startsWith('/find')){
        handler.find(req, res);
    }else if(req.url.startsWith('/search')){
        handler.search(req, res);
    }
    else if(req.url.startsWith('/sousuo')){
        handler.sousuo(req, res);
    }else if(req.url.startsWith('/sou')){
        handler.sou(req, res);
    }else if(req.url == '/add'){
        handler.add(req, res);
    }/*else if(req.url.startsWith ('/dele')){
        handler.dele(req, res);
    }*/
    else if(req.url.startsWith ('/throw')){
        handler.throw(req, res);
    }
    else if(req.url.startsWith ('/delete')){
        handler.delete(req, res);
    }else if(req.url.startsWith('/modify')){
        handler.modify(req, res);
    }
    else if(req.url.startsWith('/concern')){
        handler.concern(req, res);
    }
    else if(req.url.startsWith('/huifu')){
        handler.huifu(req, res);
    }
    else if(req.url.startsWith('/xingming')){
        handler.xingming(req, res);
    }else if(req.url.startsWith('/update')){
        handler.update(req, res);
    }else if(req.url == '/logout'){
        handler.logout(req, res);
    }else{
        fs.readFile(path.join('./public', req.url), function (err, data){
            res.end(data);
        });
    }
}